package com.foodplus.www.api;

import com.foodplus.www.foodplus.MyApp;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by WangZhiChao on 2016/11/2.
 */

public class ParamManager {

    public static final HashMap<String, String> MAP = new HashMap<>();
    private MyApp app = MyApp.getInstance();
    private static ParamManager manager;

    private ParamManager() {
    }

    public static ParamManager getInstance() {
        if (manager == null) {
            manager = new ParamManager();
        }
        return manager;
    }

    private String getToken() {
        return app.getToken();
    }

    private String getKey() {
        return app.getKey();
    }

    public Map<String, String> getMyAssetParams() {
        Map<String, String> params = new HashMap<>();
        params.put("act", "member_index");
        params.put("op", "my_asset");
        params.put("client", "android");
        params.put("token", getToken());
        params.put("key", getKey());
        return params;
    }

    public Map<String, String> getMemberParams() {
        Map<String, String> params = new HashMap<>();
        params.put("client", "android");
        params.put("token", getToken());
        params.put("key", getKey());
        return params;
    }

    public Map<String, String> getSendCodeParams(String phone) {
        Map<String, String> sendCodeParams = new HashMap<>();
        sendCodeParams.put("act", "connect");
        sendCodeParams.put("op", "get_sms_captcha");
        sendCodeParams.put("client", "client");
        sendCodeParams.put("type", "4");
        sendCodeParams.put("token", getToken());
        sendCodeParams.put("phone", phone);
        return sendCodeParams;
    }

    public Map<String, String> getLoginParams(String code, String phone) {
        Map<String, String> loginParams = new HashMap<>();
        loginParams.put("captcha", code);
        loginParams.put("username", phone);
        loginParams.put("client", "android");
        loginParams.put("token", getToken());
        loginParams.put("login_type", "1");
        return loginParams;
    }

    public Map<String, String> getBasketParams() {
        Map<String, String> map = new HashMap<>();
        map.put("client", "android");
        map.put("token", getToken());
        map.put("key", getKey());
        return map;
    }

    //获取店铺的表单
    public Map<String, String> getShopParams() {
        HashMap<String, String> map = new HashMap<>();
        map.put("act", "goods_cms_special");
        map.put("op", "cms_special");
        map.put("client", "android");
        map.put("curpage", "1");
        map.put("token", "749a036dc06ae8b3a120848995a9f306");
        return map;
    }

    //获取店铺中商品的表单
    public Map<String, String> getGoodParams(String id) {
        HashMap<String, String> map = new HashMap<>();
        map.put("act", "app");
        map.put("op", "goods_special");
        map.put("client", "android");
        map.put("curpage", "1");
        map.put("token", getToken());
        map.put("key", getKey());
        map.put("special_id", id);
        return map;
    }

    //获取单个商品的表单
    public Map<String, String> getSipGoodParams(String id) {
        HashMap<String, String> map = new HashMap<>();
        map.put("act", "goods");
        map.put("op", "goods_detail");
        map.put("client", "android");
        map.put("token", getToken());
        map.put("key", getKey());
        map.put("goods_id", id);
        return map;
    }

    //获取Tag的表单
    public Map<String, String> getTagParams(String id) {
        HashMap<String, String> map = new HashMap<>();
        map.put("act", "goods");
        map.put("op", "goods_list");
        map.put("client", "android");
        map.put("curpage", "1");
        map.put("token", getToken());
        map.put("tag_id", id);
        return map;
    }


    public Map<String, String> getHomeParams() {
        Map<String, String> params = new HashMap<>();
        params.put("act", "app");
        params.put("op", "index1");
        params.put("client", "android");
        params.put("curpage", "1");
        params.put("token", getToken());
        params.put("key", getKey());
        return params;
    }

    public Map<String, String> getSpecialMap(int mSpecialType) {
        Map<String, String> map = new HashMap<>();
        map.put("act", "app");
        map.put("op", "special_programa");
        map.put("curpage", "1");
        map.put("special_type", mSpecialType + "");
        map.put("client", "android");
        map.put("token", getToken());
        map.put("key", getKey());
        return map;
    }

    //当商品数量改变时调用
    public Map<String, String> getChangeNumMap(int num,String cartId) {
        Map<String, String> map = new HashMap<>();
        map.put("quantity", num+"");
        map.put("cart_id", cartId);
        map.put("client", "android");
        map.put("token", getToken());
        map.put("key", getKey());
        return map;
    }




    //向服务器提交数据
    public Map<String ,String> addGoodMap(String id){
        Map<String ,String> map = new HashMap<>();
        map.put("quantity","1");
        map.put("client","android");
        map.put("key",getKey());
        map.put("token",getToken());
        map.put("goods_id",id);
        return map;
    }
}
